package com.cty.controller;

import com.cty.pojo.User;
import org.apache.commons.io.FileUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.ServletContext;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.File;
import java.io.IOException;
import java.net.http.HttpRequest;
import java.util.Map;
import java.util.UUID;

/**
 * @Auther: cty
 * @Date: 2020/3/12 17:14
 * @Description:  控制器
 * @version: 1.0
 */
@Controller
public class LoginController {
    @RequestMapping("{page}")
    public String main(@PathVariable String page){
        return page;
    }

    @RequestMapping("login")
    public String login(User user, HttpServletRequest req){
        if(user.getName().equals("admin") && user.getPwd().equals("123")){
            HttpSession session = req.getSession();
            session.setAttribute("user", user);
            return "main";
        }
        return "redirect: /springmvc8/login.jsp";
    }
}
